package com.cheng.dreams.sample.presenter.home;

import android.content.Context;

import com.cheng.dreams.sample.contract.home.HomeContract;
import com.cheng.dreams.sample.entity.request.BaseRequest;
import com.cheng.dreams.sample.entity.response.BaseResponse;
import com.cheng.dreams.sample.entity.response.HomeBannerEntity;
import com.cheng.dreams.sample.net.HandleErrorObserver;
import com.cheng.dreams.sample.presenter.BasePresenter;


/**
 * Created by Snow on 2017/3/4.
 * Description:
 */

public class HomePresenter extends BasePresenter implements HomeContract.Presenter {
    private HomeContract.View mView;

    public HomePresenter(HomeContract.View view, Context mContext) {
        super(mContext);
        mView = view;
    }
    @Override
    public void onBanner() {
        mView.showLoading();
        mService.getHomeBanner()
                .compose(mObservableTransformer)
                .subscribe(new HandleErrorObserver<BaseResponse<HomeBannerEntity>>(mView, new BaseRequest()) {
                    @Override
                    public void onSuccess(BaseResponse<HomeBannerEntity> response) {
                        mView.onBannerSuccess(response.getData().getBanner());
                    }
                });
    }
}
